<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        .box{width:100px;background: #ccc;display:none;}
    </style>
</head>
<body>
    <input type="button" value="按钮" id="btn">
    <div class="box">要显示的内容</div>
</body>
<script>

    var oBtn = document.querySelector("#btn");
    var oBox = document.querySelector(".box");

    oBtn.onclick = function(eve){
        var e = eve || window.event;

        oBox.style.display = "block";

        // IE低版本：e.cancelBubble = true;
        // 正常：e.stopPropagation();
        // if(e.stopPropagation){
        //     e.stopPropagation()
        // }else{
        //     e.cancelBubble = true;
        // }

        stopBubble(e);

    }
    
    document.onclick = function(){
        oBox.style.display = "none";
    }
    


    function stopBubble(e){
        if(e.stopPropagation){
            e.stopPropagation()
        }else{
            e.cancelBubble = true;
        }
    }
</script>
</html>